package com.ziyun.erp.web.modules.storeMaterialIn.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ziyun.erp.modules.storeMaterialIn.entity.StoreMaterialInEntity;
import com.ziyun.erp.modules.storeMaterialIn.service.StoreMaterialInService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 门店耗材入库表
 *
 * @author xueqz
 * @email 
 * @date 2018-12-13 15:08:29
 */
@RestController
@RequestMapping("storeMaterialIn/storematerialin")
public class StoreMaterialInController {
    @Autowired
    private StoreMaterialInService storeMaterialInService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("storeMaterialIn:storematerialin:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = storeMaterialInService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{inId}")
    @RequiresPermissions("storeMaterialIn:storematerialin:info")
    public R info(@PathVariable("inId") Integer inId){
        StoreMaterialInEntity storeMaterialIn = storeMaterialInService.selectById(inId);

        return R.ok().put("storeMaterialIn", storeMaterialIn);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("storeMaterialIn:storematerialin:save")
    public R save(@RequestBody StoreMaterialInEntity storeMaterialIn){
        storeMaterialInService.insert(storeMaterialIn);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("storeMaterialIn:storematerialin:update")
    public R update(@RequestBody StoreMaterialInEntity storeMaterialIn){
        ValidatorUtils.validateEntity(storeMaterialIn);
        storeMaterialInService.updateAllColumnById(storeMaterialIn);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("storeMaterialIn:storematerialin:delete")
    public R delete(@RequestBody Integer[] inIds){
        storeMaterialInService.deleteBatchIds(Arrays.asList(inIds));

        return R.ok();
    }
    /**
     * 信息
     */
    @RequestMapping("/getStoreMaterialInByApplyNo/{applyNo}")
    public R getStoreMaterialInByApplyNo(@PathVariable("applyNo") String applyNo){
        System.out.println("applyNo"+applyNo);
        return storeMaterialInService.getStoreMaterialInByApplyNo(applyNo);
    }


}
